package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class FINALPFactory extends AbstractTokenVisitorFactory {

	private static FINALPFactory INSTANCE;
	
	private FINALP1Factory finalp1Factory ;
	private LambdaFactory lambdaFactory;
	
	public static FINALPFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new FINALPFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			finalp1Factory = FINALP1Factory.getInstance();
			lambdaFactory = LambdaFactory.getInstance();
		}
	};
	
	
	private FINALPFactory() throws Exception {
	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return finalp1Factory.makeChainedVisitor(lambdaFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return finalp1Factory.makeChainedVisitor(lambdaFactory.makeVisitor());
	}
	
	
}
